unit Options;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
  System.Variants,
  FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
  FMX.Edit, FMX.Layouts;

type
  TFrame1 = class(TFrame)
    GroupBox1: TGroupBox;
    Layout1: TLayout;
    Edit1: TEdit;
    Label1: TLabel;
    Layout2: TLayout;
    Edit2: TEdit;
    Label2: TLabel;
    Button1: TButton;
    AniIndicator1: TAniIndicator;
    Timer1: TTimer;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FramePaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
  private
    { Private declarations }
  public
    { Public declarations }
    function PreCompare(key: string): boolean;
  end;

implementation

uses System.IniFiles, key;
{$R *.fmx}

procedure TFrame1.Button1Click(Sender: TObject);
var
  Ini: TIniFile;
begin
  AniIndicator1.Enabled := True;
  Timer1.Enabled := True;
  Ini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'App.cfg');
  Ini.WriteString('Activation', 'AppID', key.GetSerialNum);
  Ini.WriteString('Activation', 'AppKey',
    key.StringToHex(GoogleAuthenticatorCode(key.GetSerialNum), '-'));
  Ini.UpdateFile;
  PreCompare(Edit1.Text);
  FreeAndNil(Ini);
end;

procedure TFrame1.FramePaint(Sender: TObject; Canvas: TCanvas;
  const ARect: TRectF);
begin
  if Edit1.Text <> String.Empty then
    exit;
  Edit1.Text := key.GetSerialNum;
end;

function TFrame1.PreCompare(key: string): boolean;
begin

end;

procedure TFrame1.Timer1Timer(Sender: TObject);
begin
  AniIndicator1.Enabled := False;
  Timer1.Enabled := False;
end;

end.
